home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / DirectShow_WinXP / VMR / Cube / vcdplyer.h < prev   
Encoding:
C/C++ Source or Header  |  2001-10-08  |  4.1 KB  |  147 lines

  1. //------------------------------------------------------------------------------
  2. // File: vcdplyer.h
  3. //
  4. // Desc: DirectShow sample code - header file for CMpegMovie class
  5. //
  6. // Copyright (c) 1994 - 2001, Microsoft Corporation.  All rights reserved.
  7. //------------------------------------------------------------------------------
  8.  
  9. #include <ddraw.h>
  10. #define D3D_OVERLOADS
  11. #include <d3d.h>
  12.  
  13.  
  14. /* -------------------------------------------------------------------------
  15. ** CMpegMovie - an Mpeg movie playback class.
  16. ** -------------------------------------------------------------------------
  17. */
  18. enum EMpegMovieMode { MOVIE_NOTOPENED = 0x00,
  19.                       MOVIE_OPENED = 0x01,
  20.                       MOVIE_PLAYING = 0x02,
  21.                       MOVIE_STOPPED = 0x03,
  22.                       MOVIE_PAUSED = 0x04 };
  23.  
  24.  
  25.  
  26. #define NUM_CUBE_VERTICES (4*6)
  27.  
  28. BOOL VerifyVMR(void);
  29.  
  30. struct StreamInfo
  31. {
  32.     RECT SourceRect;
  33.     BOOL bTexture;
  34. };
  35.  
  36. struct StreamSize
  37. {
  38.     float cx;
  39.     float cy;
  40. };
  41.  
  42.  
  43. class CMpegMovie :
  44.     public CUnknown,
  45.     public IVMRImageCompositor
  46. {
  47.  
  48. private:
  49.     bool DoesSupportNonPow2CondCap(LPDIRECT3DDEVICE7 pD3DDevice);
  50.     bool DoesSupportLinearCap(LPDIRECT3DDEVICE7 pD3DDevice);
  51.     bool DoesSupportAnisoCap(LPDIRECT3DDEVICE7 pD3DDevice);
  52.     DWORD m_dwTexMirrorWidth;
  53.     DWORD m_dwTexMirrorHeight;
  54.     DWORD m_dwRegister;
  55.     // Our state variable - records whether we are opened, playing etc.
  56.     EMpegMovieMode  m_Mode;
  57.     HANDLE          m_MediaEvent;
  58.     HWND            m_hwndApp;
  59.     int             m_iDuration;
  60.     GUID            m_TimeFormat;
  61.     bool            m_bInitCube;
  62.  
  63.     StreamInfo m_StreamInfo[16];
  64.  
  65.     HRESULT FrameMove(LPDIRECT3DDEVICE7 pd3dDevice, FLOAT fTimeKey);
  66.     D3DVERTEX               m_pCubeVertices[NUM_CUBE_VERTICES];
  67.  
  68.     HRESULT AllocateTextureMirror(LPDIRECTDRAWSURFACE7 pddsVideo,
  69.                                   DWORD* dwWidth, DWORD* dwHeight,
  70.                                   bool bNonPow2Cond);
  71.     LPDIRECTDRAWSURFACE7    m_pDDSTextureMirror;
  72.  
  73.     IFilterGraph*               m_Fg;
  74.     IGraphBuilder*              m_Gb;
  75.     IMediaControl*              m_Mc;
  76.     IMediaSeeking*              m_Ms;
  77.     IMediaEvent*                m_Me;
  78.     IVMRWindowlessControl*      m_Wc;
  79.  
  80.  
  81.     HRESULT AddVideoMixingRendererToFG(DWORD dwStreams);
  82.  
  83. public:
  84.     STDMETHODIMP SetStreamMediaType(DWORD dwStrmID, AM_MEDIA_TYPE* pmt, BOOL fTexture);
  85.      CMpegMovie(HWND hwndApplication);
  86.     ~CMpegMovie();
  87.  
  88.     DECLARE_IUNKNOWN
  89.     STDMETHODIMP NonDelegatingQueryInterface(REFIID, void**);
  90.  
  91.     STDMETHODIMP InitCompositionTarget(
  92.         IUnknown* pD3DDevice,
  93.         LPDIRECTDRAWSURFACE7 pddsRenderTarget
  94.         );
  95.  
  96.     STDMETHODIMP TermCompositionTarget(
  97.         IUnknown* pD3DDevice,
  98.         LPDIRECTDRAWSURFACE7 pddsRenderTarget
  99.         )
  100.     {
  101.         return S_OK;
  102.     }
  103.  
  104.     STDMETHODIMP CompositeImage(
  105.         IUnknown* pD3DDevice,
  106.         LPDIRECTDRAWSURFACE7 pddsRenderTarget,
  107.         AM_MEDIA_TYPE* pmtRenderTarget,
  108.         REFERENCE_TIME rtStart,
  109.         REFERENCE_TIME rtEnd,
  110.         DWORD dwMappedClrBkgnd,
  111.         VMRVIDEOSTREAMINFO* pVideoStreamInfo,
  112.         UINT cStreams
  113.         );
  114.  
  115.  
  116.     HRESULT         OpenMovie(TCHAR achFileName[][MAX_PATH], DWORD dwNumFiles);
  117.     DWORD           CloseMovie();
  118.  
  119.     BOOL            PlayMovie();
  120.     BOOL            PauseMovie();
  121.     BOOL            StopMovie();
  122.  
  123.     OAFilterState   GetStateMovie();
  124.  
  125.     HANDLE          GetMovieEventHandle();
  126.     long            GetMovieEventCode();
  127.  
  128.     BOOL            PutMoviePosition(LONG x, LONG y, LONG cx, LONG cy);
  129.     BOOL            RepaintVideo(HWND hwnd, HDC hdc);
  130.  
  131.     REFTIME         GetDuration();
  132.     REFTIME         GetCurrentPosition();
  133.     BOOL            SeekToPosition(REFTIME rt,BOOL bFlushData);
  134.  
  135.     void            SetFullScreenMode(BOOL bMode);
  136.  
  137.     void            DisplayModeChanged() {
  138.         if (m_Wc) {
  139.             m_Wc->DisplayModeChanged();
  140.         }
  141.     }
  142. };
  143.  
  144. RECT GetSourceRectFromMediaType(const AM_MEDIA_TYPE *pMediaType);
  145. LPBITMAPINFOHEADER GetbmiHeader(const AM_MEDIA_TYPE *pMediaType);
  146.  
  147.